package com.ruoyi.api.kehu;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaHospitalDepartment;
import com.ruoyi.system.service.IJiajiaHospitalDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 医院科室Controller
 * 
 * @author mrwang
 * @date 2024-05-06
 */
@Controller
@RequestMapping("/api/kehu/hospital/department")
public class ApiHospitalDepartmentController extends BaseController
{

    @Autowired
    private IJiajiaHospitalDepartmentService jiajiaHospitalDepartmentService;


    /**
     * 查询医院科室列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaHospitalDepartment jiajiaHospitalDepartment)
    {
        startPage();
        List<JiajiaHospitalDepartment> list = jiajiaHospitalDepartmentService.selectJiajiaHospitalDepartmentList(jiajiaHospitalDepartment);
        return getDataTable(list);
    }

    /**
     * 新增保存医院科室
     */
    @Log(title = "医院科室新增", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaHospitalDepartment jiajiaHospitalDepartment)
    {
        return toAjax(jiajiaHospitalDepartmentService.insertJiajiaHospitalDepartment(jiajiaHospitalDepartment));
    }

    /**
     * 修改保存医院科室
     */
    @Log(title = "医院科室编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaHospitalDepartment jiajiaHospitalDepartment)
    {
        return toAjax(jiajiaHospitalDepartmentService.updateJiajiaHospitalDepartment(jiajiaHospitalDepartment));
    }

    /**
     * 删除医院科室
     */
    @Log(title = "医院科室删除", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaHospitalDepartmentService.deleteJiajiaHospitalDepartmentByIds(ids));
    }
}
